/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package biz;

import dao.FitnessProgramDAO;
import entity.FitnessProgram;
import java.sql.SQLException;
import java.util.ArrayList;

/**
 *
 * @author Young Ran
 */
public class FitnessProgramBO {
    
    //DISPLAY FITNESSPROGRAMS:
    public ArrayList<FitnessProgram> getAllFitnessProgram() throws SQLException{
        return new FitnessProgramDAO().getAllFitnessProgram();
    }
    
    public void addFitnessProgram(FitnessProgram item) throws SQLException
    {
        new FitnessProgramDAO().addFitnessProgram(item);
    }
    public void editFitnessProgram(FitnessProgram item) throws SQLException{
        new FitnessProgramDAO().editFitnessProgram(item);
    }
    public void deleteFitnessProgram(int id) throws SQLException{
        new FitnessProgramDAO().deleteFitnessProgram(id);
    }
    
    public String getName(int id) throws SQLException
    {
        ArrayList<FitnessProgram> data = new FitnessProgramDAO().getAllFitnessProgram();
        for (FitnessProgram item : data) {
            if(item.getId()==id)
            {
                return item.getName();
            }
        }
        return "";
    }
}
